<?php

class TrainerProfileReviewController extends GxController {

    public function filters() {
        return array('rights');
    }


	public function actionfrontUserReview($id) {
        $criteria = new CDbCriteria();
        $criteria->addCondition('to_user_id =' . $id);
        $statuschangeurl = Yii::app()->createUrl('trainerProfileReview/statuschange/');
        $trainerratePositive = count(ClassCourseTrainnerRate::model()->findAll('to_front_user_id=' . $id . ' AND status =' . SkillConfig::STATUS_ACTIVE));
        $trainerrateNigative = count(ClassCourseTrainnerRate::model()->findAll('to_front_user_id=' . $id . ' AND status =' . SkillConfig::STATUS_DEACTIVE));
        $url = '/users/admin/';
        $userProfile=Users::getFrontEndUser($id);
        $dataProvider = new CActiveDataProvider('TrainerProfileReview', array('criteria' => $criteria,));
        $this->render('admin', array(
            'model' => $dataProvider, 'url' => $url, 'trainerratePositive' => $trainerratePositive, 'trainerrateNigative' => $trainerrateNigative,
            'statuschangeurl' => $statuschangeurl,'userProfile'=>$userProfile
        ));
    }

    
      public function actionbackUserReview($id) {
        $criteria = new CDbCriteria();
        $criteria->addCondition('backend_user_id =' . $id);
        $statuschangeurl = Yii::app()->createUrl('trainerProfileReview/statuschange/');
        $userProfile=  Users::getBackEndUser($id);
        $trainerratePositive = count(ClassCourseTrainnerRate::model()->findAll('to_back_user_id=' . $id . ' AND status =' . SkillConfig::STATUS_ACTIVE));
        $trainerrateNigative = count(ClassCourseTrainnerRate::model()->findAll('to_back_user_id=' . $id . ' AND status =' . SkillConfig::STATUS_DEACTIVE));
        $url = '/backendUser/admin/';
        $dataProvider = new CActiveDataProvider('TrainerProfileReview', array('criteria' => $criteria,));
        $this->render('admin', array(
            'model' => $dataProvider, 'url' => $url, 'trainerratePositive' => $trainerratePositive, 'trainerrateNigative' => $trainerrateNigative,
            'statuschangeurl' => $statuschangeurl,'userProfile'=>$userProfile
        ));
    }
    public function actionStatuschange() {
        TrainerProfileReview::model()->updateByPk($_POST['id'], array('status' => $_POST['status']));
    }

}